<?php
function _setData($mysqli, $theDay, $tableVer){
    $pv=$uv=0;
    $queryDay=$mysqli->query("select count(id) as pv from ".$tableVer."_puv where theday='".$theDay."' ");
    if($queryDay->num_rows>0){
        $getData=$queryDay->fetch_assoc();
        $pv=$getData['pv'];
        $queryUv=$mysqli->query("select count(distinct(openid)) as uv from ".$tableVer."_puv where theday='".$theDay."'  ");
        $getUvData=$queryUv->fetch_assoc();
        $uv=$getUvData['uv'];
    }
    
    $queryFen=$mysqli->query("select id from ".$tableVer."_pvuv where theday='".$theDay."' limit 0, 1");
    if($queryFen->num_rows>0){
        $sql="update ".$tableVer."_pvuv set pv=".$pv.", uv=".$uv.",createtime='".date("Y-m-d H:i:s")."'  where theday='".$theDay."'  ";
        $query = $mysqli->query($sql);
    }else{
        $sql="insert into ".$tableVer."_pvuv(pv,uv,theday,createtime) values('".$pv."','".$uv."','".$theDay."','".date("Y-m-d H:i:s")."') ";
         $mysqli->query($sql);
    }
}
include '../c/config.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
$theDay=date("Y-m-d", strtotime("-1 day"));
_setData($mysqli,$theDay, $tableVer);
echo 'zuotian: ', $theDay;
echo "<br />";
$mysqli->close();

?>